﻿<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
		<span class="c-gray en">&gt;</span>
		短信管理
		<span class="c-gray en">&gt;</span>
		短信配置
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="l"> <a href="javascript:;" onclick="add_smsconfig('添加公众号','{:url('admin/Aliyun/add_smsconfig')}','700','400')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加短信</a> </span>
			</div>
			<div class="mt-10">
				<table class="table table-border table-bordered table-bg table-hover table-sort">
					<thead>
						<tr class="text-c">
							<th width="25"><input type="checkbox" name="" value=""></th>
							<th width="80">ID</th>
							<th width="100">配置名称</th>
							<th width="100">appid</th>
							<th width="120">appsecret</th>
							<th width="120">模板ID</th>
							<th width="120">签名</th>
							<th width="50">状态</th>
							<th width="50">操作</th>
						</tr>
					</thead>
					<tbody>
						{volist name="config_list" id="va"}
						<tr class="text-c">
							<td><input type="checkbox" value="{$va.id}" name="id"></td>
							<td>{$va.id}</td>
							<td>{$va.sms_name}</td>
							<td>{$va.appid}</td>
							<td>{$va.appsecret}</td>
							<td>{$va.smsid}</td>
							<td>{$va.sign}</td>
							{if condition="$va.status eq 1"}
								<td class="td-status"><span class="label label-success radius">已启用</span></td>
							{else/}
								<td class="td-status"><span class="label label-default radius">已停用</span></td>
							{/if}
							<td class="td-manage">
								<a style="text-decoration:none" onClick="smsconfig_status(this,{$va.id})" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe615;</i></a>
								<a title="编辑" href="javascript:;" onclick="smsconfig_edit('编辑','{:url('admin/Aliyun/edit_smsconfig',['id'=>$va['id']])}','1','700','400')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> 
								<a title="删除" href="javascript:;" onclick="smsconfig_del(this,{$va.id})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
							</td>
						</tr>
						{/volist}
					</tbody>
				</table>
			</div>
		</article>
	</div>
</section>
</body>
<script type="text/javascript">
/*微信配置-增加*/
function add_smsconfig(title,url,w,h){
	layer_show(title,url,w,h);
}

/*管理员-删除*/
function smsconfig_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		//此处请求后台程序，下方是成功后的前台处理……
		$.ajax({
			type:"post",
			url:"{:url('admin/Aliyun/del_sms')}",
			data:{'id':id},
			success:function(res){
				var _json = JSON.parse(res);
				if(_json.status == 1){
					$(obj).parents("tr").remove();
					layer.msg(_json.msg,{icon:1,time:1000});
				}else{
					layer.msg(_json.msg);
				}
			}
		});
		
	});
}
/*管理员-编辑*/
function smsconfig_edit(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*管理员-停用*/
function smsconfig_status(obj,id){
	layer.confirm('确认要启用吗？',function(index){
		//此处请求后台程序，下方是成功后的前台处理……
		$.ajax({
			type:"post",
			url:"{:url('admin/Aliyun/sms_status')}",
			data:{'id':id},
			success:function(res){
				var _json = JSON.parse(res);
				if(_json.status == 1){
					$(obj).parents("tr").find(".td-manage").prepend('<a onClick="smsconfig_status(this,'+id+')" href="javascript:;" title="启用" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>');
					$(obj).remove();
					layer.msg(_json.msg,{icon: 6,time:1000});
				}else{
					layer.msg(_json.msg);
				}
			}
		});
		
	});
}
</script>
</html>